/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package negocio;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jorge
 */
@Entity
@Table(catalog = "mydb2", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tarea.findAll", query = "SELECT t FROM Tarea t"),
    @NamedQuery(name = "Tarea.findByIdtarea", query = "SELECT t FROM Tarea t WHERE t.idtarea = :idtarea"),
    @NamedQuery(name = "Tarea.findByDescripcion", query = "SELECT t FROM Tarea t WHERE t.descripcion = :descripcion"),
    @NamedQuery(name = "Tarea.findByDuracion", query = "SELECT t FROM Tarea t WHERE t.duracion = :duracion"),
    @NamedQuery(name = "Tarea.findByFInicio", query = "SELECT t FROM Tarea t WHERE t.fInicio = :fInicio"),
    @NamedQuery(name = "Tarea.findByFFin", query = "SELECT t FROM Tarea t WHERE t.fFin = :fFin"),
    @NamedQuery(name = "Tarea.findByResponsable", query = "SELECT t FROM Tarea t WHERE t.responsable = :responsable"),
    @NamedQuery(name = "Tarea.findByItemsControl", query = "SELECT t FROM Tarea t WHERE t.itemsControl = :itemsControl")})
public class Tarea implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idtarea;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(nullable = false, length = 500)
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(nullable = false, length = 200)
    private String duracion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "f_inicio", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fInicio;
    @Basic(optional = false)
    @NotNull
    @Column(name = "f_fin", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fFin;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 300)
    @Column(nullable = false, length = 300)
    private String responsable;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(name = "items_control", nullable = false, length = 500)
    private String itemsControl;
    @OneToMany(mappedBy = "predecesoraIdtarea")
    private List<Tarea> tareaList;
    @JoinColumn(name = "predecesora_idtarea", referencedColumnName = "idtarea")
    @ManyToOne
    private Tarea predecesoraIdtarea;
    @JoinColumn(name = "objetivo_estrategico_idobjetivo_estrategico", referencedColumnName = "idobjetivo_estrategico", nullable = false)
    @ManyToOne(optional = false)
    private ObjetivoEstrategico objetivoEstrategicoIdobjetivoEstrategico;

    public Tarea() {
    }

    public Tarea(Integer idtarea) {
        this.idtarea = idtarea;
    }

    public Tarea(Integer idtarea, String descripcion, String duracion, Date fInicio, Date fFin, String responsable, String itemsControl) {
        this.idtarea = idtarea;
        this.descripcion = descripcion;
        this.duracion = duracion;
        this.fInicio = fInicio;
        this.fFin = fFin;
        this.responsable = responsable;
        this.itemsControl = itemsControl;
    }

    public Integer getIdtarea() {
        return idtarea;
    }

    public void setIdtarea(Integer idtarea) {
        this.idtarea = idtarea;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getDuracion() {
        return duracion;
    }

    public void setDuracion(String duracion) {
        this.duracion = duracion;
    }

    public Date getFInicio() {
        return fInicio;
    }

    public void setFInicio(Date fInicio) {
        this.fInicio = fInicio;
    }

    public Date getFFin() {
        return fFin;
    }

    public void setFFin(Date fFin) {
        this.fFin = fFin;
    }

    public String getResponsable() {
        return responsable;
    }

    public void setResponsable(String responsable) {
        this.responsable = responsable;
    }

    public String getItemsControl() {
        return itemsControl;
    }

    public void setItemsControl(String itemsControl) {
        this.itemsControl = itemsControl;
    }

    @XmlTransient
    public List<Tarea> getTareaList() {
        return tareaList;
    }

    public void setTareaList(List<Tarea> tareaList) {
        this.tareaList = tareaList;
    }

    public Tarea getPredecesoraIdtarea() {
        return predecesoraIdtarea;
    }

    public void setPredecesoraIdtarea(Tarea predecesoraIdtarea) {
        this.predecesoraIdtarea = predecesoraIdtarea;
    }

    public ObjetivoEstrategico getObjetivoEstrategicoIdobjetivoEstrategico() {
        return objetivoEstrategicoIdobjetivoEstrategico;
    }

    public void setObjetivoEstrategicoIdobjetivoEstrategico(ObjetivoEstrategico objetivoEstrategicoIdobjetivoEstrategico) {
        this.objetivoEstrategicoIdobjetivoEstrategico = objetivoEstrategicoIdobjetivoEstrategico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idtarea != null ? idtarea.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tarea)) {
            return false;
        }
        Tarea other = (Tarea) object;
        if ((this.idtarea == null && other.idtarea != null) || (this.idtarea != null && !this.idtarea.equals(other.idtarea))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "negocio.Tarea[ idtarea=" + idtarea + " ]";
    }
    
}
